package com.you.atlas.web.common.util;

import java.util.List;

@SuppressWarnings({ "rawtypes", "unchecked" }) 
public class ListUtil {

    public static ListVO split(List list) {
        ListVO arrayVO = new ListVO();
        
        if (list==null||list.size() == 0) {
            return arrayVO ;
        }
        int length = list.size();
        int size = 3;
        int arrayCount = length / size;
        int remnant = length % size;
        int i = 0;
        for (i = 0; i < arrayCount; ++i) {
            arrayVO.getDataList1().add(list.get(i * size));
            arrayVO.getDataList2().add(list.get(i * size + 1));
            arrayVO.getDataList3().add(list.get(i * size + 2));
        }
        if (remnant > 0) {
            arrayVO.getDataList1().add(list.get(i * size));
            if (remnant > 1) {
                arrayVO.getDataList2().add(list.get(i * size + 1));
            }
        }
        return arrayVO;
    }
}
